class Solution {
public:
    string removeKdigits(string num, int k) {
        string st = "";
        int remain = num.size() - k;
        if (remain <= 0) return "0";
        for (char& c : num)
        {
            while (k != 0 && st.size() >= 1 && st.back() > c)
            {
                st.pop_back();
                k--;
            }
            st.push_back(c);
        }
        st = st.substr(0, remain);
        while (*st.begin() == '0' && st.size() > 1)
            st.erase(st.begin());
        return st;
    }
};

class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int ret = -0x3f3f3f3f;
        int n = nums.size();
        vector<int> dp(n + 1);
        for (int i = 1; i <= n; i++)
        {
            dp[i] = max(dp[i - 1] + nums[i - 1], nums[i - 1]);
            ret = max(ret, dp[i]);
        }
        return ret;
    }
};